package com.asset.dispoal.business.mediation.service.common;

import com.asset.dispoal.business.mediation.domain.db.entity.ReduceOperate;
import com.asset.dispoal.business.mediation.domain.db.mapper.ReduceOperateMapper;
import com.asset.dispoal.business.mediation.dto.ReduceLogsResponse;
import com.asset.dispoal.business.mediation.service.converter.MediationConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tech.mhuang.pacebox.core.ddd.BaseCommand;
import tech.mhuang.pacebox.springboot.protocol.Result;

import java.util.List;

/**
 * @description:
 * @author: yf
 * @date: 2022-08-26 16:20:23
 */
@Component
public class GetReduceLogsCommand implements BaseCommand<String, Result<List<ReduceLogsResponse>>> {

    @Autowired
    private ReduceOperateMapper reduceOperateMapper;

    @Override
    public Result<List<ReduceLogsResponse>> execute(String caseId) {
        List<ReduceOperate> operateList = reduceOperateMapper.getLogsByCaseId(caseId);
        List<ReduceLogsResponse> result = MediationConverter.INSTANCE.dosToResRO(operateList);
        return Result.ok(result);
    }
}
